﻿
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Net.Sockets;
using System.Reflection;
using System.Web;
namespace HBase {
    public class UtilPackets {



        static public byte[] WriteSuccess(  String value) {
            byte[] d = new byte[1460];
            int begin = 0;
          //  begin = WriteLine(d, begin, "HTTP/1.0 200 OK");
            begin = WriteLine(d, begin, "Content-Type: application/json");
            begin = WriteLine(d, begin, "Connection: close");
            begin = WriteLine(d, begin, "Access-Control-Allow-Origin: *");
            begin = WriteLine(d, begin, "Access-Control-Allow-Headers: Content-Type,X-Token,token");
            begin = WriteLine(d, begin, "Access-Control-Allow-Credentials: true");
            begin = WriteLine(d, begin, "Access-Control-Allow-Methods: GET,POST,OPTIONS");
            begin = WriteLine(d, begin, "Cache-Control:no-cache");
            begin = WriteLine(d, begin, "Server:gk 4.16");
            begin = WriteLine(d, begin, "");
            begin = WriteLine(d, begin, value);

        byte[] r=   UtilByteArr.cut(d, 0, begin);

            return r;

        }
        public static int WriteLine(byte[] a, int begin, String d) {
            byte[] b = System.Text.Encoding.UTF8.GetBytes(d); 
            begin = UtilByteArr.append(a, begin, b);
            a[begin] = 10;
            return begin + 1;

        }
    }
}
